<template>
  <div class="page-container">
    <ex_header_spiler :title="$tt('label_base_info')"></ex_header_spiler>
    <ex_super_desc v-bind="baseOption" :data="form" :attrs="$defaultDetailDescAttrs" />
    </el-form>

    <!--  下架记录-->
    <ex_header_spiler :title="$t('label_put_down_record')">
    </ex_header_spiler>
    <ex-table-auto
      class="el-table-nowwarp"
      :data="putDownRows"
      :autoFill="false"
      :autoPage="false"
      border>

      <el-table-column type="index" label="#" width="43" align="center"></el-table-column>
      <el-table-column prop="srcLocationCode" :label="$tt('label_source_location')" min-width="10"></el-table-column>
      <el-table-column prop="customerName" :label="$tt('label_customer_name')"  min-width="10" align="left"></el-table-column>

      <el-table-column prop="skuName"  :label="$tt('label_sku_only_code')+ '/SN'" min-width="20" align="left">
        <template slot-scope="scope">
          {{scope.row.skuName }} - {{scope.row.snCode ? 'SN:' +scope.row.snCode: scope.row.skuOnlyCode }}
        </template>
      </el-table-column>
      <el-table-column prop="planMoveNum" :label="$tt('label_plan_count')" min-width="6" align="center"></el-table-column>
      <el-table-column prop="moveOutNum" :label="$tt('label_plan_reorg_count')" min-width="6" align="center"></el-table-column>
      <el-table-column prop="moveInNum"  :label="$tt('label_move_in_count')" min-width="6" align="center"></el-table-column>
      <el-table-column prop="moveInContainerCode"  :label="$tt('label_put_down_container')" min-width="8" align="center"></el-table-column>

      <el-table-column prop="gmtCreate"  :label="$tt('label_put_down_time')" min-width="12" align="center">
        <template slot-scope="scope">
          {{ $dateFormat(scope.row.gmtCreate) }}
        </template>
      </el-table-column>
      <el-table-column prop="creator"  :label="$tt('label_operate_user')" min-width="12" align="center"></el-table-column>

    </ex-table-auto>

    <!-- 上架记录 -->
    <ex_header_spiler :title="$t('label_put_on_record')">
    </ex_header_spiler>

    <ex-table-auto
      class="el-table-nowwarp"
      :data="putOnRows"
      :autoFill="false"
      :autoPage="false"
      border>

      <el-table-column type="index" label="#" width="43" align="center"></el-table-column>
      <el-table-column prop="targetLocationCode" :label="$tt('label_target_location')" min-width="10"></el-table-column>
      <el-table-column prop="customerName" :label="$tt('label_customer_name')"  min-width="10" align="left"></el-table-column>

      <el-table-column prop="skuName"  :label="$tt('label_sku_only_code')+ '/SN'" min-width="20" align="left">
        <template slot-scope="scope">
          {{scope.row.skuName }} - {{scope.row.snCode ? 'SN:' +scope.row.snCode: scope.row.skuOnlyCode }}
        </template>
      </el-table-column>

      <el-table-column prop="moveInNum"  :label="$tt('label_move_in_count')" min-width="26" align="center"></el-table-column>
      <el-table-column prop="gmtCreate"  :label="$tt('label_putaway_time')" min-width="12" align="center">
        <template slot-scope="scope">
          {{ $dateFormat(scope.row.gmtCreate) }}
        </template>
      </el-table-column>
      <el-table-column prop="creator"  :label="$tt('label_operate_user')" min-width="12" align="center"></el-table-column>

    </ex-table-auto>

  </div>
</template>

<script>
import router_params from '@/mixin/router_params';
export default {
  name: "reorg_detail",
  title: 'title_reorg_detail',
  mixins: [router_params],
  data() {
    return {

      putDownRows:[],

      putOnRows:[],

      form: {},
      detailList: [],
      baseOption: {
        model: [
          { key: 'orderNo', label: 'label_reorg_code', },
          { key: 'bizType', label: 'label_business_type', },
          { key: 'type', label: 'label_reorg_type', formatter: (r, c, v, i) => this.$enumShow(v, "ReorgOrderTypeEnum"), },

          { key: 'status', label: 'label_status', formatter: (r, c, v, i) => this.$enumShow(v, "ReorgOrderStatusEnum"), },

          { key: 'remark', label: 'label_remark', },
          { key: 'waitMoveOutNum', label: 'label_wait_take_down_count', },
          { key: 'waitMoveInNum', label: 'label_wait_put_count',  },
          { key: 'creator', label: 'label_create_user', },
          { key: 'gmtCreate', label: 'label_create_time', formatter: (r, c, v, i) => this.$dateFormat(v) },
        ],
      }

    }
  },
  computed: {
    TOB() {
      return this.form.bizType == 'TOB'
    },

  },

  methods: {
    init_order(id) {

      let _this = this

      let data = {
        id
      }
      this.$ajax({
        url: "/wms-api/inside/ReorgOrderRpc/detail.json",
        method: 'post',
        data,
        success: (res) => {
          this.form = res.data
        },
      })

      this.$ajax({
        url: "/wms-api/inside/ReorgOrderRpc/selectDetailPage.json",
        data:{orderId: id},
        success: (res) => {
          if(res && res.data && res.data.rows){
            _this.putDownRows = res.data.rows.filter(e=>e.commitType == 'TAKE_DOWN')
            _this.putOnRows = res.data.rows.filter(e=>e.commitType == 'PUT_AWAY')
          }
        },
      })

    },
    init_data_default(params) {
      // this.table.urlParams.orderId = params.id
      // this.$refs.SuperTable.loadData({ orderId: params.id })
      this.init_order(params.id)
    },
  }

}
</script>

<style scoped></style>
